import { GiftBook, GiftBookCreate, GiftBookQuery, GiftBookUpdate } from '@/types/giftBook'
import http from '@/utils/request'

// 获取礼簿列表
export function getGiftBookList(params: GiftBookQuery) {
    return http.post<{
        msg: string
        code: number
        data: {
            records: GiftBook[]
            pageNumber: number
            pageSize: number
            totalPage: number
            totalRow: number
        }
    }>('/system/giftBooks/selectPage', {
        ...params,
        pageNum: params.pageNum || 1,
        pageSize: params.pageSize || 10,
        params: {}
    })
}

// 获取礼簿详情
export function getGiftBookDetail(id: string) {
    return http.get<GiftBook>(`/system/giftBooks/${id}`)
}

// 创建礼簿
export function createGiftBook(data: GiftBookCreate) {
    return http.post<GiftBook>('/system/giftBooks', data)
}

// 更新礼簿
export function updateGiftBook(data: GiftBookUpdate) {
    return http.put<GiftBook>(`/system/giftBooks`, data)
}

// 删除礼簿
export function deleteGiftBook(id: string) {
    return http.delete<void>(`/system/giftBooks/removeById/${id}`)
}

// 获取礼簿统计数据
export function getGiftBookDashboard() {
    return http.get<{
        msg: string
        code: number
        data: {
            guestCount: number
            totalAmount: number
        }
    }>('/system/giftBooks/dashboard')
}

// 获取分享二维码
export function getShareQrCode(data: {
    bookId: string
    type: string
    number: number
}) {
    return http.post<{
        msg: string
        code: number
        data: string
    }>('/system/giftBooks/share', data)
} 